﻿<DockableContent
    x:Class="Poet.Views.RegexBuilderView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ae="http://icsharpcode.net/sharpdevelop/avalonedit"
    Title="RegexBuilderView" Height="300" Width="300">

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="{Binding [TextHeight], Mode=TwoWay, FallbackValue='1*', TargetNullValue='1*', Converter={DefaultConverter '1*'}}"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="{Binding [Text1Height], Mode=TwoWay, FallbackValue='1*', TargetNullValue='1*', Converter={DefaultConverter '1*'}}"/>
        </Grid.RowDefinitions>

        <GroupBox Header="{Localizing Text}">
            <Border BorderThickness="1" CornerRadius="2" BorderBrush="LightGray">
                <ae:TextEditor ShowLineNumbers="True" Document="{Binding Document}" FontFamily="Consolas">
                    <ae:TextEditor.Resources>
                        <Style TargetType="ae:TextArea">
                            <Setter Property="ShowCurrentLine" Value="False"/>
                        </Style>
                    </ae:TextEditor.Resources>
                    <ae:TextEditor.Options>
                        <ae:TextEditorOptions
                            ShowTabs="True"
                            ShowSpaces="True"
                            ShowEndOfLine="True"
                            ShowBoxForControlCharacters="True"/>
                    </ae:TextEditor.Options>
                </ae:TextEditor>
            </Border>
        </GroupBox>

        <GridSplitter Grid.Row="1" HorizontalAlignment="Stretch" Height="4"/>

        <Grid Grid.Row="2">
            <Grid.RowDefinitions>
                <RowDefinition Height="{Binding [RegexHeight], Mode=TwoWay, FallbackValue='1*', TargetNullValue='1*', Converter={DefaultConverter '1*'}}"/>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="{Binding [Regex1Height], Mode=TwoWay, FallbackValue='1*', TargetNullValue='1*', Converter={DefaultConverter '1*'}}"/>
            </Grid.RowDefinitions>

            <GroupBox Header="{Localizing Regex}">
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition/>
                        <ColumnDefinition/>
                    </Grid.ColumnDefinitions>

                    <Border BorderThickness="1" CornerRadius="2" BorderBrush="LightGray">
                        <ae:TextEditor ShowLineNumbers="True" Document="{Binding Pattern}" FontFamily="Consolas">
                            <ae:TextEditor.Resources>
                                <Style TargetType="ae:TextArea">
                                    <Setter Property="ShowCurrentLine" Value="False"/>
                                </Style>
                            </ae:TextEditor.Resources>
                            <ae:TextEditor.Options>
                                <ae:TextEditorOptions
                            ShowTabs="True"
                            ShowSpaces="True"
                            ShowEndOfLine="True"
                            ShowBoxForControlCharacters="True"/>
                            </ae:TextEditor.Options>
                        </ae:TextEditor>
                    </Border>


                    <StackPanel Grid.Column="1">
                        <StackPanel.Resources>
                            <Style TargetType="Button">
                                <Setter Property="Width" Value="24"></Setter>
                            </Style>
                        </StackPanel.Resources>
                        <StackPanel Orientation="Horizontal">
                            <Button Content="\"/>
                            <Button Content="^"/>
                            <Button Content="$"/>
                            <Button Content="*"/>
                            <Button Content="+"/>
                            <Button Content="?"/>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <Button Content="{}{n}"/>
                            <Button Content="{}{n,}"/>
                            <Button Content="{}{n,m}"/>
                            <Button Content="."/>
                            <Button Content="( )"/>
                            <Button Content="(?: )"/>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <Button Content="(?= )"/>
                            <Button Content="(?! )"/>
                            <Button Content="|"/>
                            <Button Content="[ ]"/>
                            <Button Content="[^ ]"/>
                            <Button Content="[\b]"/>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <Button Content="\n"/>
                            <Button Content="\r"/>
                            <Button Content="\t"/>
                            <Button Content="[ ]"/>
                            <Button Content="[^ ]"/>
                            <Button Content="[\b]"/>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <Button Content="\b"/>
                            <Button Content="\w"/>
                            <Button Content="\d"/>
                            <Button Content="\s"/>
                            <Button Content="[^ ]"/>
                            <Button Content="[\b]"/>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <Button Content="\B"/>
                            <Button Content="\W"/>
                            <Button Content="\D"/>
                            <Button Content="\S"/>
                            <Button Content="[^ ]"/>
                            <Button Content="[\b]"/>
                        </StackPanel>
                    </StackPanel>
                </Grid>
            </GroupBox>

            <GridSplitter Grid.Row="1" HorizontalAlignment="Stretch" Height="4"/>

            <GroupBox Grid.Row="2" Header="{Localizing Matches}">
                <DataGrid ItemsSource="{Binding Matches}"></DataGrid>
            </GroupBox>
        </Grid>
    </Grid>

</DockableContent>
